package com.xueba.manage.course.controller;

import com.xueba.api.course.CourseControllerApi;
import com.xueba.framework.common.model.response.QueryResponseResult;
import com.xueba.framework.common.model.response.ResponseResult;
import com.xueba.framework.domain.course.CourseBase;
import com.xueba.framework.domain.course.ext.CourseInfo;
import com.xueba.framework.domain.course.request.CourseListRequest;
import com.xueba.manage.course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Kidy
 * @date 2020/7/31 11:48
 */
@RestController
public class CourseController implements CourseControllerApi {

    @Autowired
    private CourseService courseService;

    /**
     *
     * @param page 当前页码
     * @param size 显示记录数
     * @param courseListRequest 用于扩展...
     * @return 课程列表
     */
    @Override
    @GetMapping("/base/list/{page}/{size}") //设置接口路径
    public QueryResponseResult<CourseInfo> findCourseList(
            @PathVariable("page") int page,
            @PathVariable("size") int size,
            CourseListRequest courseListRequest) {
        //调用service层的方法
        return courseService.findCourseList(page, size, courseListRequest);
    }

    @Override
    @PostMapping("/base/add")
    public ResponseResult addCourseBase(@RequestBody CourseBase courseBase) {
        return courseService.addCourseBase(courseBase);
    }
}





